package com.jiangwh.web.restful.impl;

import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.apache.cxf.jaxrs.model.wadl.Description;
import org.apache.cxf.jaxrs.model.wadl.Descriptions;
import org.apache.cxf.jaxrs.model.wadl.DocTarget;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jiangwh.domain.services.Business;
import com.jiangwh.web.restful.Facade;

@Component("facade")
@Path("/")
//@InInterceptors (interceptors = {"org.apache.cxf.transport.common.gzip.GZIPOutInterceptor"})
public class FacadeImpl implements Facade {

	@Autowired
	Business service;
	
	@GET
	@Path("/get/schoolKey/{schoolName}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取学校的Key值", target = DocTarget.METHOD),
		@Description(value = "每个业务方法都需要带上这个Key值", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getSchoolKey(@PathParam("schoolName") String schoolName) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("key", service.getSchoolKey(schoolName));
		return Response.status(200).entity(map).build();
	}

	@Override
	@GET
	@Path("/get/onlineStatus/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取用户的在线状态", target = DocTarget.METHOD),
		@Description(value = "返回用户的在线状态", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getOnlineStatus(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@GET
	@Path("/get/accountInfo/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取用户账户信息", target = DocTarget.METHOD),
		@Description(value = "返回用户账户信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getAccountInfo(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@GET
	@Path("/get/accountDetail/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取用户账务信息", target = DocTarget.METHOD),
		@Description(value = "返回用户账务信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getAccountDetail(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@GET
	@Path("/get/onlineDetail/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取用户上网明细信息", target = DocTarget.METHOD),
		@Description(value = "返回用户上网明细信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getOnlineDetail(@PathParam("userId")String userId, int pageNo,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@GET
	@Path("/get/accountFlow/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取用户账务流水信息", target = DocTarget.METHOD),
		@Description(value = "返回用户账务流水信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getAccountFlow(@PathParam("userId")String userId, int pageNo,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@POST
	@Path("/post/suspendUser/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "用户自助暂停", target = DocTarget.METHOD),
		@Description(value = "返回用户操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response postSuspendUser(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@POST
	@Path("/post/resumeUser/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "用户自助恢复", target = DocTarget.METHOD),
		@Description(value = "返回用户操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response postResumeUser(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@PUT
	@Path("/post/resumeUser/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "用户自助充值", target = DocTarget.METHOD),
		@Description(value = "返回用户自助充值结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response putCardRecharge(@PathParam("userId")String userId, @QueryParam("p")String password,
			@QueryParam("chargeCadeType")String chargeCardType, @QueryParam("cardNo")String cardNo,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@POST
	@Path("/post/userInfo")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "更新用户信息", target = DocTarget.METHOD),
		@Description(value = "返回更新用户信息操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response postUserInfo(@QueryParam("phoneInfo")String userinfo,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}
	
	@Override
	@DELETE
	@Path("/delete/userInfo")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "删除用户信息", target = DocTarget.METHOD),
		@Description(value = "返回删除用户信息操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response deleteUserInfo(@QueryParam("phoneInfo")String userinfo,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}
	
	
	@Override
	@GET
	@Path("/get/userInfo/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "查询用户信息", target = DocTarget.METHOD),
		@Description(value = "返回用户信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getUserInfo(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@GET
	@Path("/get/userMABInfo/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "查询用户MAB信息", target = DocTarget.METHOD),
		@Description(value = "返回用户MAB信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getUserMABInfo(@PathParam("userId")String userId, int pageNo,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@POST
	@Path("/post/kickOnlineUser/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "踢用户下线", target = DocTarget.METHOD),
		@Description(value = "返回踢人操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response postkickOnlineUser(@PathParam("userId")String userId,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@PUT
	@Path("/put/deviceAlias/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "踢用户下线", target = DocTarget.METHOD),
		@Description(value = "返回踢人操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response putDeviceAlias(@PathParam("userId")String userId, String mac, String type,
			String name,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@DELETE
	@Path("/delete/deviceAlias/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "删除设备别名信息", target = DocTarget.METHOD),
		@Description(value = "返回操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response deleteDeviceAlias(@PathParam("userId")String userId, String mac, String type,
			String name,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@POST
	@Path("/post/priorityGrab/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "修改设备优先级信息", target = DocTarget.METHOD),
		@Description(value = "返回操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response postPriorityGrab(@PathParam("userId")String userId, String priorityStr,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@DELETE
	@Path("/delete/mABBindInfo/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "修改设备优先级信息", target = DocTarget.METHOD),
		@Description(value = "返回操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response deleteMABBindInfo(@PathParam("userId")String userId, String mac,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@DELETE
	@Path("/delete/bindUserInfo/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "修改设备优先级信息", target = DocTarget.METHOD),
		@Description(value = "返回操作结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response deleteBindUserInfo(@PathParam("userId")String userId, String mac,@HeaderParam("SCHOOLKEY")String schoolKey) {
		ResponseBuilder builder = Response.status(200);
		builder.header("delete","ok");
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		builder.entity(map);
		return builder.build();
	}

	@Override
	@GET
	@Path("/get/aPInfo/{userId}")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "获取AP信息", target = DocTarget.METHOD),
		@Description(value = "返回AP信息", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response getAPInfo(@PathParam("userId")String APIP,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@PUT
	@Path("/put/phoneInfo")
	@Produces(value={MediaType.APPLICATION_JSON})
	@Descriptions({
		@Description(value = "上传手机信息", target = DocTarget.METHOD),
		@Description(value = "返回上传结果", target = DocTarget.RETURN),
		@Description(value = "Request", target = DocTarget.REQUEST),
		@Description(value = "Response", target = DocTarget.RESPONSE),
		@Description(value = "Resource", target = DocTarget.RESOURCE) 
	})
	public Response putPhoneInfo(@QueryParam("phoneInfo")String info,@HeaderParam("SCHOOLKEY")String schoolKey) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("111", "111");
		return Response.status(200).entity(map).build();
	}

	@Override
	@HEAD
	@Path("/head/login")
	public Response headLogin(@QueryParam("userName")String userName,@QueryParam("password")String password) {
		ResponseBuilder builder = Response.status(200);
		String Authorization = "Basic ";
		Authorization += service.headLogin(userName, password);
		service.test();
		builder.header("Authorization",Authorization );
		builder.entity("");
		return builder.build();
	}
}
